package Batch::Cluster::Result;
use Moose;


our $VERSION = '0.01';


has 'results' => (
    traits => ['Array'],
    is => 'rw',
    isa => 'ArrayRef[Any]',
    default => sub { [] },
    handles => {
      all_results => 'elements',
      add_result => 'push',
      get_result => 'shift',
    },
);

use overload bool => \&to_bool,
             fallback => 1;

sub to_bool {
  my $self = shift;
  map { $_->result() or return 0 } $self->all_results();
  return 1;
}

sub add_ordered_result {
  my ($self, $item, $pos) = @_;
  $self->results->[$pos] = $item;
}

__PACKAGE__->meta->make_immutable;

no Moose;

1;

__END__

=head1 NAME

Batch::Cluster::Result - Almacena los resultados generados por Batch::Cluster.

=head1 DESCRIPTION

La clase Batch::Cluster::Result contendrá una serie de objetos
GRID::Machine::Result, producto de las ejecuciones realizadas en un cluster
mediante el módulo Batch::Cluster.

=head1 AUTHOR

Juan Pablo Chinea Martin, E<lt>alu2592@etsii.ull.esE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2011 by Juan Pablo Chinea Martin

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.


=cut
